package com.tannm.doan.taskmanager.database;

public class DataRowEvent extends DataRow {
	// Table field indexes for field select speedup
	public static class Fid {
		public static final int ID = 0;
		public static final int CODE = 1;
		public static final int NAME = 2;
		public static final int TASK = 3;
		public static final int CONTACT = 4;
		public static final int SUBJECT = 5;
		public static final int CONTENT = 6;
	};

	// Table definition
	private final DataField[] tableDef = {
			new DataField(Fid.ID, "_ID", DataField.Type.INT, true, true),
			new DataField(Fid.CODE, "code", DataField.Type.TEXT, true,false),
			new DataField(Fid.NAME, "name", DataField.Type.TEXT, true,false),
			new DataField(Fid.TASK, "task", DataField.Type.INT, true,false),
			new DataField(Fid.CONTACT, "contact", DataField.Type.INT, true,false),
			new DataField(Fid.SUBJECT, "subject", DataField.Type.TEXT, true,false),
			new DataField(Fid.CONTENT, "content", DataField.Type.TEXT, true,false),
			};

	// fields
	private String code = "";
	private String name = "";
	private int task;
	private int contact;
	private String subject = "";
	private String content = "";

	// methods
	public DataRowEvent(Database userdb) {
		super(userdb);
		setTableDefinition(tableDef);
	}

	@Override
	public boolean validate() {
		if (subject.length() > 0) {
			return true;
		}
		return false;
	}

	@Override
	public void setValuesForDataRow() {
		clearContentValues();

		value(Fid.SUBJECT).set(getSubject());
	}

	@Override
	public void getValuesFromDataRow() {
		setSubject(value(Fid.SUBJECT).asString());
	}

	@Override
	public String getTableName() {
		return Database.sTableNameNotes;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getCode() {
		return code;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getSubject() {
		return subject;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getContent() {
		return content;
	}


	public void setTask(int task) {
		this.task = task;
	}


	public int getTask() {
		return task;
	}


	public void setContact(int contact) {
		this.contact = contact;
	}


	public int getContact() {
		return contact;
	}

}
